package com.pss.product.controller;

import com.pss.common.component.LoginUserHolder;
import com.pss.common.controller.CURDController;
import com.pss.product.entity.Product;
import com.pss.product.service.ProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/pdt")
@Api(value = "/pdt", description = "商品", tags = "商品接口")
public class ProductController extends CURDController<ProductService, Product> {

    @Autowired
    private ProductService productService;
    @Autowired
    private LoginUserHolder loginUserHolder;

    @ApiOperation(value = "查询商品详情", httpMethod = "POST", notes = "查询商品详情")
    @PostMapping("/productInfo")
    public String pInfo(@RequestParam("pId") Integer pId){
        return productService.pInfo(pId);
    }

    @ApiOperation(value = "获取用户", httpMethod = "GET", notes = "获取用户")
    @GetMapping("/currentUser")
    public Map currentUser() {
        return loginUserHolder.getCurrentUser();
    }

}
